package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.CwBlindBox;
import com.ruoyi.system.service.ICwBlindBoxService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 盲盒管理Controller
 * 
 * @author hyx
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/cwbox")
public class CwBlindBoxController extends BaseController
{
    @Autowired
    private ICwBlindBoxService cwBlindBoxService;

    /**
     * 查询盲盒管理列表
     */
//    @RequiresPermissions("system:cwbox:list")
    @GetMapping("/list")
    public TableDataInfo list(CwBlindBox cwBlindBox)
    {
        startPage();
        List<CwBlindBox> list = cwBlindBoxService.selectCwBlindBoxList(cwBlindBox);
        return getDataTable(list);
    }

    /**
     * 导出盲盒管理列表
     */
//    @RequiresPermissions("system:cwbox:export")
    @Log(title = "盲盒管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CwBlindBox cwBlindBox)
    {
        List<CwBlindBox> list = cwBlindBoxService.selectCwBlindBoxList(cwBlindBox);
        ExcelUtil<CwBlindBox> util = new ExcelUtil<CwBlindBox>(CwBlindBox.class);
        util.exportExcel(response, list, "盲盒管理数据");
    }

    /**
     * 获取盲盒管理详细信息
     */
//    @RequiresPermissions("system:cwbox:query")
    @GetMapping(value = "/{blindBoxId}")
    public AjaxResult getInfo(@PathVariable("blindBoxId") Long blindBoxId)
    {
        return success(cwBlindBoxService.selectCwBlindBoxByBlindBoxId(blindBoxId));
    }

    /**
     * 新增盲盒管理
     */
//    @RequiresPermissions("system:cwbox:add")
    @Log(title = "盲盒管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CwBlindBox cwBlindBox)
    {
        return toAjax(cwBlindBoxService.insertCwBlindBox(cwBlindBox));
    }

    /**
     * 修改盲盒管理
     */
//    @RequiresPermissions("system:cwbox:edit")
    @Log(title = "盲盒管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CwBlindBox cwBlindBox)
    {
        return toAjax(cwBlindBoxService.updateCwBlindBox(cwBlindBox));
    }

    /**
     * 删除盲盒管理
     */
//    @RequiresPermissions("system:cwbox:remove")
    @Log(title = "盲盒管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{blindBoxIds}")
    public AjaxResult remove(@PathVariable Long[] blindBoxIds)
    {
        return toAjax(cwBlindBoxService.deleteCwBlindBoxByBlindBoxIds(blindBoxIds));
    }
}
